package pers.cz.business;

import pers.cz.mapper.HostsAddressMapper;
import pers.cz.model.HostsAddress;
import pers.cz.mybatisPlugin.PageRowBounds;
import pers.cz.pub.AbstractBusiness;

import java.util.List;

/**
 * @program: PostGirl-panent
 * @description: TestConfigBusiness
 * @author: Cheng Zhi
 * @create: 2021-08-20 15:34
 **/
public class TestConfigBusiness extends AbstractBusiness {

    public List<HostsAddress> getAllHostsAddress() {

        List<HostsAddress> hostsAddresses = this.getMapper(HostsAddressMapper.class).selectAllHostsAddress();
        return hostsAddresses;
    }

    /**
     * 查询所有的地址信息
     * @return
     */
    public List<HostsAddress> queryAllAddress() {

        List<HostsAddress> hostsAddresses = this.getMapper(HostsAddressMapper.class).selectAllHostsAddress();
        return hostsAddresses;
    }

    /**
     * 分页查询所有地址
     * @param pageStart
     * @param pageLimit
     * @return
     */
    public List<HostsAddress> queryAllAddressByPage(Integer pageStart, Integer pageLimit) {

        PageRowBounds pageRowBounds = new PageRowBounds(pageStart, pageLimit);
        List<HostsAddress> hostsAddresses = this.getMapper(HostsAddressMapper.class).selectAllHostsAddressByPage(pageRowBounds);

        return hostsAddresses;
    }

    /**
     * 修改测试地址信息
     * @param hostsAddress
     * @return
     */
    public Integer updateAddress(HostsAddress hostsAddress) {

        int count = this.getMapper(HostsAddressMapper.class).updateByPrimaryKeySelective(hostsAddress);
        return count;
    }

    /**
     * 根据主键删除测试地址
     * @param id
     * @return
     */
    public Integer deleteAddress(Long id) {

        int count = this.getMapper(HostsAddressMapper.class).deleteByPrimaryKey(id);
        return count;
    }

    /**
     * 添加测试地址
     * @param address
     * @return
     */
    public Integer addAdddress(HostsAddress address) {

        int count = this.getMapper(HostsAddressMapper.class).insert(address);
        return count;
    }

    /**
     * 获取总数
     * @return
     */
    public Integer getAddressTotalNum() {

        int count = this.getMapper(HostsAddressMapper.class).getAddressTotalNum();
        return count;
    }

    /**
     * 模糊查询
     * @param enviName
     * @param hostsAddress
     * @return
     */
    public List<HostsAddress> queryAddress(String enviName, String hostsAddress) {

        List<HostsAddress> hostsAddressList = this.getMapper(HostsAddressMapper.class).queryAddressByFuzzy(enviName, hostsAddress);
        return hostsAddressList;
    }

}
